/*--------------------------------------------------------------------------------*/
#ifndef __INPUT_SYSTEM__
#define __INPUT_SYSTEM__
/*--------------------------------------------------------------------------------*/
#include "primitives.h"
#include "object.h"
#include "util.h"
#include "timer.h"
#include "table.h"
#include "input_key.h"
#include "math_vector_2.h"
/*--------------------------------------------------------------------------------*/
#define LOCAL_KeyCount 	323
/*--------------------------------------------------------------------------------*/
class INPUT_SYSTEM : public OBJECT
{

	// -- PUBLIC

public:

	DECLARE_REF( INPUT_SYSTEM );
    DECLARE_SINGLETON( INPUT_SYSTEM );

    // .. CONSTRUCTORS

    INPUT_SYSTEM();
    virtual ~INPUT_SYSTEM();

    // .. METHODS

    VOID Initialize();

    VOID Update( const TIMER & time_step );

    BOOL IsKeyPressed( INT key ) const;
    BOOL IsKeyReleased( INT key ) const;
    BOOL IsKeyJustPressed( INT key ) const;
    BOOL IsKeyJustReleased( INT key ) const;

    const MATH_VECTOR_2 & GetCursorPosition() const
    {
    	return CurrentCursorPosition;
    }

    VOID StartTextCatcher();
    VOID EndTextCatcher();

    const TEXT & GetCurrentText() const
    {
    	return CurrentText;
    }

    BOOL IsTextCatchingFinished( TEXT & final_text ) const
    {
    	if( !TextCatchingIsOn )
    	{
    		final_text = CurrentText;
    		return true;
    	}

    	return false;
    }

    // -- PRIVATE

private :

    // .. METHODS

    VOID SetCurrentKeyState( INT key, BOOL state );
    VOID SetPreviousKeyState( INT key, BOOL state );

    VOID CatchText();

    // .. ATTRIBUTES

    TABLE< BOOL, LOCAL_KeyCount >
		CurrentKeyStateTable,
		PreviousKeyStateTable;
    TEXT
    	CurrentText;
    BOOL
    	TextCatchingIsOn;
    MATH_VECTOR_2
    	CurrentCursorPosition,
    	PreviousCursorPosition;

    
};
/*--------------------------------------------------------------------------------*/
#endif
